



#delimit;
set more off;

cd "C:\....\Replication files";
	
use "ENMI - replication.dta", clear;
		
		
#delimit;
		
xtreg pvote
	c.ensh_mi##i.inc_cab_l, fe robust;
	estimates store ml_simple;
	
		gen lastdateingovt=year if inc_cab_l==1;
		gen lastdateinopp= year if inc_cab_l==0;
		egen firstelection = min(year), by(country);
			replace lastdateingovt= 0 if inc_cab_l!=1;
			replace lastdateinopp=0 if inc_cab_l!=0;
	forv i=1/10{;
			
	replace lastdateingovt=L`i'.lastdateingovt if lastdateingovt==0 & inc_cab_l!=1;
	replace lastdateinopp=L`i'.lastdateinopp if lastdateinopp==0 & inc_cab_l!=0;

	};
		replace lastdateingovt=firstelection if lastdateingovt==.;
	
	gen yearsinopp= year - lastdateingovt;
	gen yearsingov= year - lastdateinopp;
				

		egen challengerparty=total(inc_cab_l) , by(party);
			replace challengerparty=-1 if challengerparty>=1;
			replace challengerparty=challengerparty + 1;
			replace challengerparty= 1 if lastdateingovt==firstelection;
		
xtreg pvote
	c.ensh_mi##i.inc_cab_l pvote_l
	c.GDPgrowth##i.inc_cab_l
	c.moderate##i.inc_cab_l
 majelect  
 L1.1.coalgov L1.1.prime_minister
 challengerparty yearsinopp yearsingov n_inc_p , fe robust  ;
  
estimates store coalc_full_fe;	

testnl _b[c.ensh_mi#1.inc_cab_l] + _b[c.ensh_mi]
== _b[c.ensh_mi] ;




				#delimit;
set more off;
xtreg pvote
	1.inc_cab_l#c.ensh_mi pvote_l 1.inc_cab_l#c.GDPgrowth
	1.inc_cab_l#c.moderate 
	 majelect 
	   L1.1.coalgov L1.1.prime_minister
  yearsingov n_inc_p 
  if inc_cab_l==1 , fe robust;
		
testnl _b[c.ensh_mi#1.inc_cab_l] == 0 ;

		estimates store coalc_onlyincumbents_fe;
		
	
		
		
						#delimit;
											
xtreg pvote
	c.ensh_mi c.GDPgrowth pvote_l
	moderate 
		 majelect  
		   L1.1.coalgov L1.1.prime_minister
 challengerparty yearsinopp n_inc_p 
	if inc_cab_l==0 , fe robust ;

	testnl _b[c.ensh_mi] == 0 ;
	
	
		estimates store coalc_onlyopposition_fe;




	

#delimit;
 esttab coalc_onlyopposition_fe coalc_onlyincumbents_fe  coalc_full_fe  
			using "figures\Table A12 - FEs govt controls.rtf", replace 
		b (%10.3f) se scalars("aic AIC" "bic BIC" "rmse Root Mean Squared Error" "chi2 \u0935?{\super 2}" "ll Log-Likelihood" ) 
		obslast star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
		label mtitles (  "Opposition" "Incumbents" "Full") nogaps
title (\label{})
		
		
order(ensh_mi 
1.inc_cab_l#c.ensh_mi 
moderate 
1.inc_cab_l#c.moderate 
GDPgrowth
1.inc_cab_l#c.GDPgrowth 
1.inc_cab_l 

1L.prime_minister 1L.coalgov n_inc_p  
 challengerparty yearsinopp yearsingov 
majelect pvote_l _cons ) 
keep(ensh_mi 
1.inc_cab_l#c.ensh_mi 
moderate 
1.inc_cab_l#c.moderate 
GDPgrowth
1.inc_cab_l#c.GDPgrowth 
1.inc_cab_l 

1L.prime_minister 1L.coalgov n_inc_p  
 challengerparty yearsinopp yearsingov 
majelect pvote_l _cons )


coeflabels(
ensh_mi "ENMI"  
1.inc_cab_l "Incumbent"
1.inc_cab_l#c.ensh_mi "Incumbent X ENMI"
GDPgrowth "GDP Growth Rate" 
1.inc_cab_l#c.GDPgrowth "Incumbent X GDP Growth Rate"
1.inc_cab_l#c.moderate "Incumbent X Moderated Position"
moderate "Moderated Position"
majelect "Majoritarian Election"
pvote_l "% Vote{\sub t-1}"
_cons "Constant"
1L.prime_minister "Controlled PM since last election"
 1L.coalgov "Coalition Govt"
 n_inc_p  "# of coal parties"
 challengerparty "Challenger Party"
 yearsinopp "Years in Opp"
 yearsingov "Years in Gov" );

